package com.ca.ui.core.adapter;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.ca.ui.core.util.ImageUtils;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.holder.BannerImageHolder;

import java.util.List;

public class BannerImageAdapter extends BannerAdapter<String, BannerImageHolder> {

    private final Context context;

    public BannerImageAdapter(Context context, List<String> datas) {
        super(datas);
        this.context = context;
    }

    @Override
    public BannerImageHolder onCreateHolder(ViewGroup parent, int viewType) {

        ImageView imageView = new ImageView(parent.getContext());
        imageView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        return new BannerImageHolder(imageView);
    }

    @Override
    public void onBindView(BannerImageHolder holder, String data, int position, int size) {
        ImageUtils.loadRoundImage(context, data, holder.imageView, 30);
    }
}
